package com.desheng.bigdata.flink.stream

import org.apache.flink.streaming.api.scala._

object ScalaFlinkStreamWordCountApp {
    def main(args: Array[String]): Unit = {
        val env = StreamExecutionEnvironment.getExecutionEnvironment

        val inputs = env.socketTextStream("bigdata01", 9999)

        inputs.flatMap(_.split("\\s+"))
                .map(WordCount(_, 1))
                .keyBy(wc => wc.word)
                .sum("count")
                .print()
                .setParallelism(2)

        env.execute(s"${ScalaFlinkStreamWordCountApp.getClass.getSimpleName}")
    }
}